package com.service;

import java.rmi.RemoteException;

import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.ServiceException;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;

public class Test {
	
	private static final String URL="http://10.100.255.5:7001/life/services/CommonAgentQueryService?wsdl";

	public static void main(String[] args) throws ServiceException, RemoteException {

			
		String webServiceNameSpace = "TransData";

		Service service = new Service();
		Call call = (Call) service.createCall();
		call.setTargetEndpointAddress(URL);
		call.setOperationName("getAgentQueryInfo");
//		call.setOperationName(new QName(webServiceNameSpace,"getAgentQueryInfo"));
		
		call.addParameter("TradeType", XMLType.XSD_STRING, ParameterMode.IN);
		call.addParameter("TradeCode", XMLType.XSD_STRING, ParameterMode.IN);
		call.addParameter("SubTradeCode", XMLType.XSD_STRING, ParameterMode.IN);
		call.addParameter("Key", XMLType.XSD_STRING, ParameterMode.IN);
		
		call.setReturnType(XMLType.XSD_STRING);
			
		Object[] paramValues = new Object[] { "WEBSITE", "004", "1", "FCB141ED4FAE92BE918B536B15780FDA" };
		String result = (String) call.invoke(paramValues);

		System.out.println("result is " + result);
		
		
		
	}
	
	public static void testRPC() throws AxisFault{
		
		System.err.println("testRPC");
		
        RPCServiceClient sc = new RPCServiceClient();
        Options options = sc.getOptions();
        EndpointReference targetErp = new EndpointReference(URL);
        options.setTo(targetErp);

        Object[] opAddEntryArgs = new Object[] { "Test 1.0" };

        Class[] classes = new Class[] { String.class };

        QName opAddEntry = new QName("http://bangjia.svac.ws.css.ermsuite.neusoft.com", "doService");

        sc.getOptions().setTimeOutInMilliSeconds(600000L);
        System.out.println(sc.invokeBlocking(opAddEntry, opAddEntryArgs, classes)[0]);

	}
}
